<template>
	<view class="login">
		<view class="top">
			<uv-navbar title="忘记密码" height="44px" titleStyle="{font-weight: bold;font-size: 1.1rem;}" bgColor="#dff8f7"
				@leftClick="leftClick"></uv-navbar>
		</view>
		<view class="userlogin">
			<view class="userlogin1">
				<uv-input placeholder="请输入您的手机号" customStyle="border:none;padding: 2%;" @change="change"></uv-input>
			</view>
			<view class="userlogin1">
				<uv-input placeholder="请输入您的密码" customStyle="border:none;padding: 2%;" @change="change"></uv-input>
			</view>
			<view class="userlogin1">
				<uv-input placeholder="确认密码" customStyle="border:none;padding: 2%;" @change="change"></uv-input>
			</view>
			<view class="userlogin1">
				<uv-input placeholder="请输入验证码" customStyle="border:none;padding: 2%;">
					<!-- vue3模式下必须使用v-slot:suffix -->
					<template v-slot:suffix>
						<uv-code ref="uCode" @change="codeChange" seconds="20" changeText="X秒重新获取"></uv-code>
						<uv-button @click="getCode" :text="tips" color="#008c8c" type="success" size="mini"></uv-button>
					</template>
				</uv-input>

			</view>
		</view>
		<view class="determine">
			<uv-button type="primary" color="#008c8c" shape="circle" text="确认修改"></uv-button>
			<button class="btn">登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tips: '',
				value: '内容'

			}
		},
		methods: {
			change(e) {
				console.log('change', e);
			},
			//返回login
			leftClick() {
				uni.navigateTo({ url: '/pages/login/login' })
				console.log('leftClick');
			},
			codeChange(text) {
				this.tips = text;
			},
			getCode() {
				if (this.$refs.uCode.canGetCode) {
					// 模拟向后端请求验证码
					uni.showLoading({
						title: '正在获取验证码'
					})
					setTimeout(() => {
						uni.hideLoading();
						// 这里此提示会被this.start()方法中的提示覆盖
						uni.showToast({
							title: '验证码已发送',
							duration: 2000
						});
						
						// 通知验证码组件内部开始倒计时
						this.$refs.uCode.start();
					}, 2000);
				} else {
					uni.showToast({
						title: '倒计时结束后再发送',
						duration: 2000
					});
					
				}
			},
		}
	}
</script>

<style lang="scss">
	@import url("/pages/password/password.css");
</style>